import pytest
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
class Test_case():
    def setup_method(self):
        self.driver=webdriver.Edge()
        self.driver.get('http://10.59.9.14:7003/')

    def teardown_method(self):
        time.sleep(10)
        self.driver.quit()

    def test_gwc(self):
        # 登录
        self.driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        time.sleep(2)
        self.driver.find_element(By.NAME,'username').send_keys('18986670716')
        self.driver.find_element(By.NAME,'password').send_keys('a123456')
        time.sleep(10)
        self.driver.find_element(By.CLASS_NAME,'finish-btn').click()
        time.sleep(3)
        # 搜索
        self.driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
        time.sleep(2)
        self.driver.find_element(By.CLASS_NAME,'search-input').send_keys('龙虾')
        self.driver.find_element(By.CLASS_NAME,'search-input-btn').click()
        time.sleep(5)
        # 加入购物车
        self.driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li/div[1]/span/a/img').click()
        time.sleep(2)
        self.driver.find_element(By.ID,'add-cart').click()
        time.sleep(5)


